package com.treemanage.treemanageback.interceptors;

import com.treemanage.treemanageback.JWTest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@Slf4j
@Component
public class LoginInterceptor implements HandlerInterceptor {
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        return true;
        //        String token = request.getHeader("Authorization");
//        log.info("拦截器拦截到请求，token为：" + token);
//        //验证tokne
//        try {
//            Map<String, Object> claims = JWTest.parseToken(token);
//            //放行
//            log.info("token验证通过");
//            return true;
//        } catch (Exception e) {
//            response.setStatus(401);
//            response.setContentType("text/html;charset=utf-8");
//            response.getWriter().write("token验证失败，请重新登录");
//            return false;
//        }
    }
}
